package com.scedu.config;

import com.lly835.bestpay.config.WxPayConfig;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/*
微信支付配置
 */
@Component
public class WechatPayConfig {

    @Autowired
    private WechatAccountConfig wechatAccountConfig;
    @Bean
    BestPayServiceImpl bestPayService(){
        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        WxPayConfig  wxPayConfig =new WxPayConfig();
        wxPayConfig.setAppId(wechatAccountConfig.getMpAppId());          //公众号Id
        wxPayConfig.setAppSecret(wechatAccountConfig.getMpAppSecret());
        //支付商户资料
        wxPayConfig.setMchId(wechatAccountConfig.getMchId());
        wxPayConfig.setMchKey(wechatAccountConfig.getMchKey());
        wxPayConfig.setKeyPath(wechatAccountConfig.getKeyPath());
        wxPayConfig.setNotifyUrl(wechatAccountConfig.getNotifyUrl());

        bestPayService.setWxPayConfig(wxPayConfig);
        return bestPayService;
    }

}
